﻿// /------------------------------------------------------------
// | FMTH Header File
// | 
// | File Name    : FMSplashScreen.h
// | Created By   : cfluck
// | Creation Date: mercredi, novembre 02, 2005
// | 
// | Purpose      : 
// |	http://www.codeproject.com/miscctrl/csplashscreenex.asp
// |	by John O'Byrne 01/10/2002
//  ------------------------------------------------------------
#ifndef _FMSPLASHSCREEN_H_
#define _FMSPLASHSCREEN_H_


#pragma once

#define CSS_FADEIN		0x0001
#define CSS_FADEOUT		0x0002
#define CSS_FADE		CSS_FADEIN | CSS_FADEOUT
#define CSS_SHADOW		0x0004
#define CSS_CENTERSCREEN	0x0008
#define CSS_CENTERAPP		0x0010
#define CSS_HIDEONCLICK		0x0020

#define CSS_TEXT_NORMAL		0x0000
#define CSS_TEXT_BOLD		0x0001
#define CSS_TEXT_ITALIC		0x0002
#define CSS_TEXT_UNDERLINE	0x0004

typedef BOOL (WINAPI* FN_ANIMATE_WINDOW)(HWND,DWORD,DWORD);

class CSplashScreen : public CWnd
{
	DECLARE_DYNAMIC(CSplashScreen)

public:
	CSplashScreen();
	virtual ~CSplashScreen();

	BOOL Create(CWnd *pWndParent,LPCTSTR szText=NULL,DWORD dwTimeout=2000,DWORD dwStyle=CSS_FADE | CSS_CENTERSCREEN | CSS_SHADOW);
	BOOL SetBitmap(UINT nBitmapID,short red=-1,short green=-1,short blue=-1);
	BOOL SetBitmap(LPCTSTR szFileName,short red=-1,short green=-1,short blue=-1);

	void Show();
	void Hide();

	void SetText(LPCTSTR szText);
	void SetTextFont(LPCTSTR szFont,int nSize,int nStyle);
	void SetTextFontCopyright(LPCTSTR szFont,int nSize,int nStyle);
	void SetTextDefaultFont();
	void SetTextColor(COLORREF crTextColor);
	void SetTextRect(CRect& rcText);
	void SetTextFormat(UINT uTextFormat);
	
	static void	CSplashScreen::AddLine(CString strLine)
	{
		if(s_pCurrentSplash && s_pCurrentSplash->GetSafeHwnd())
			s_pCurrentSplash->AddInformationTextLine(strLine);
	}
	void AddInformationTextLine(CString strLine);
	void ModifyLastInformationTextLine(CString strLine);

	void SetTextVersions(LPCTSTR szText);
	void SetTextVersionsColor(COLORREF crTextColor);
	void SetTextVersionsRect(CRect& rcText);
	void SetTextVersionsFormat(UINT uTextFormat);
	
	void SetTextBuild(LPCTSTR szText);
	void SetTextBuildColor(COLORREF crTextColor);
	void SetTextBuildRect(CRect& rcText);
	void SetTextBuildFormat(UINT uTextFormat);
	
	void SetTextCopyright(LPCTSTR szText);
	void SetTextCopyrightColor(COLORREF crTextColor);
	void SetTextCopyrightRect(CRect& rcText);
	void SetTextCopyrightFormat(UINT uTextFormat);
	
protected:	
	FN_ANIMATE_WINDOW m_fnAnimateWindow;
	CWnd *m_pWndParent;
	CBitmap m_bitmap;
	CFont m_myFont;
	CFont m_myFontCopyright;
	HRGN m_hRegion;
	
	DWORD m_dwStyle;
	DWORD m_dwTimeout;
	
	CString m_strTextCopyright;
	CRect m_rcTextCopyright;
	UINT m_uTextCopyrightFormat;
	COLORREF m_crTextCopyrightColor;

	CString m_strTextVersions;
	CRect m_rcTextVersions;
	UINT m_uTextVersionsFormat;
	COLORREF m_crTextVersionsColor;

	CString m_strTextBuild;
	CRect m_rcTextBuild;
	UINT m_uTextBuildFormat;
	COLORREF m_crTextBuildColor;

	CString m_strText;
	CString m_strFirstLine;
	CString m_strSecondLine;
	CString m_strThirdLine;
	CRect m_rcText;
	UINT m_uTextFormat;
	COLORREF m_crTextColor;

	int m_nBitmapWidth;
	int m_nBitmapHeight;
	int m_nxPos;
	int m_nyPos;

	static CSplashScreen *s_pCurrentSplash;
		
	HRGN CreateRgnFromBitmap(HBITMAP hBmp, COLORREF color);
	void DrawWindow(CDC *pDC);

protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam);
protected:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
};


#endif //_FMSPLASHSCREEN_H_
//  ------------------------------------------------------------
